﻿using System.Data;
using EntitiesTM;
using System.Data.SqlClient;

namespace DataAccess
{
    public class DaDepartment
    {
        public DataTable selAllDepartment(string companyid)
        {
            string strCommandText = "selAllDepartment" + companyid;
            return SqlHelper.ExecuteData(CommandType.StoredProcedure, strCommandText, null);
        }

        public void insDepartment(EnDepartment department, string companyid)
        {
            string strCommandText = "insDepartment" + companyid;
            SqlParameter[] paraLocal = new SqlParameter[3];
            paraLocal[0] = new SqlParameter("@DepartmentName", department.departmentName);
            paraLocal[1] = new SqlParameter("@DepartmentNameAlt", department.departmentNameAlt);
            paraLocal[2] = new SqlParameter("@DepartmentDescription", department.departmentDescription);
            SqlHelper.ExecuteNonQuery(CommandType.StoredProcedure, strCommandText, paraLocal);
        }

        public void updDepartment(EnDepartment department, string companyid)
        {
            string strCommandText = "updDepartment" + companyid;
            SqlParameter[] paraLocal = new SqlParameter[4];
            paraLocal[0] = new SqlParameter("@DepartmentName", department.departmentName);
            paraLocal[1] = new SqlParameter("@DepartmentNameAlt", department.departmentNameAlt);
            paraLocal[2] = new SqlParameter("@DepartmentDescription", department.departmentDescription);
            paraLocal[3] = new SqlParameter("@DepartmentID", department.departmentID);
            SqlHelper.ExecuteNonQuery(CommandType.StoredProcedure, strCommandText, paraLocal);
        }

        public void delDepartment(EnDepartment department, string companyid)
        {
            string strCommandText = "delDepartment" + companyid;
            SqlParameter[] paraLocal = new SqlParameter[1];
            paraLocal[0] = new SqlParameter("@DepartmentID", department.departmentID);
            SqlHelper.ExecuteNonQuery(CommandType.StoredProcedure, strCommandText, paraLocal);
        }
    }
}
